//package com.tiancheng.trade.order.util.cmq.queue.consumer;
//
//import com.alibaba.fastjson.JSON;
//import com.tiancheng.trade.commom.core.utils.JsonUtil;
//import com.tiancheng.trade.order.bo.ums.QrcOrderCacheBO;
//import com.tiancheng.trade.commom.core.enums.MessageTypeEnum;
//import com.tiancheng.trade.order.service.QrOrderService;
//import com.tiancheng.trade.order.util.EnumUtil;
//import com.tiancheng.trade.order.util.cmq.MessageParsing;
//import com.tiancheng.trade.commom.core.data.MessageBody;
//import com.tiancheng.trade.order.util.cmq.model.QueueMessage;
//import jakarta.annotation.Resource;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//
///**
// * @Author: likailun
// * @Description: 消费码过期处理
// * @Date: create in 2021/9/15 9:59 上午
// */
//@Slf4j
//@Component
//public class QrOrderQueueConsumer extends AbstractCustomQueueConsumer {
//
//    //@Value(value = "${mq.queue}")
//    private String midQueue="";
//    @Resource
//    private MessageParsing messageParsing;
//    @Resource
//    private QrOrderService qrOrderService;
//
//    @Override
//    public void handle(QueueMessage message) throws Exception {
//        // 实现逻辑
//        log.info("cmq接收到二维码订单过期消息:{}", JSON.toJSONString(message));
//        MessageBody msgBody = messageParsing.getQueueBody(message.getMsgBody());
//        String messageType = msgBody.getMessageType();
//        if(StringUtils.isEmpty(messageType)) {
//            messageType = msgBody.getCmdStr();
//        }
//
//        MessageTypeEnum msgType = EnumUtil.getEnumByCode(MessageTypeEnum.class, messageType);
//        if(msgType == null) {
//            throw new RuntimeException("未查询到指定消息类型");
//        }
//        switch (msgType) {
//            case qrc_close:
//                final QrcOrderCacheBO qrcOrderCacheBO = JsonUtil.fromJson(JsonUtil.toJsonString(msgBody.getData()), QrcOrderCacheBO.class);
//                final boolean closed = this.qrOrderService.closeOrder(qrcOrderCacheBO);
//                log.info("关闭二维码订单结果：{}",closed);
//                break;
//            default:
//                log.warn("未知的消息类型：{}",msgType);
//        }
//    }
//
//    @Override
//    public String getQueueName() {
//        return midQueue;
//    }
//
//    @Override
//    public Integer getPollingWaitSeconds() {
//        return 5;
//    }
//
//}
